#include("/common/_layout.html")
#@layout()
#define layoutHead()
	<title>班级编辑</title>
#end
#define layoutBody()
	<body>
		<div class="page-content-wrap">
				<form class="layui-form" lay-filter="formedit">
					<input type="hidden" name="class_id">
					<div class="layui-tab" style="margin: 0;">
						<ul class="layui-tab-title">
							<li><a id="a_goback_url" href="javascript:window.history.back();">班级列表</a></li>
							<li class="layui-this">班级编辑</li>
						</ul>
						<div class="layui-tab-content">
							<div class="layui-tab-item"></div>
							<div class="layui-tab-item layui-show">
								<div class="layui-form-item">
									<label class="layui-form-label">班级名称：</label>
									<div class="layui-input-block">
										<input type="text" name="class_name" required lay-verify="required" placeholder="请输入班级名称" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">开班时间：</label>
									<div class="layui-input-block">
										<input type="text" name="open_time" required lay-verify="required" placeholder="请输入开班时间" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this, istime: false, format: 'YYYY-MM-DD'})">
									</div>
								</div>
								<div class="layui-form-item" style="display: none;">
									<label class="layui-form-label">老师数量：</label>
									<div class="layui-input-block">
										<input type="text" name="teacher_num" placeholder="请输入老师数量" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item" style="display: none;">
									<label class="layui-form-label">学生数量：</label>
									<div class="layui-input-block">
										<input type="text" name="student_num" placeholder="请输入学生数量" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">年级：</label>
									<div class="layui-input-block">
										<select id="grade_id" name="grade_id" lay-verify="required">
											<option value="1">托班</option>
											<option value="2">小班</option>
											<option value="3">中班</option>
											<option value="4">大班</option>
										</select>
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">状态：</label>
									<div class="layui-input-block">
										<select name="class_state" lay-verify="required">
											<option value="1">启用</option>
											<option value="0">禁用</option>
										</select>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-form-item" style="padding-left: 10px;">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
						</div>
					</div>
				</form>
		</div>
		<script src="/static/js/jquery.formHelp.js" type="text/javascript" charset="utf-8"></script>
		<script>
			var url_cat_id = getUrlParam("cat_id");
			var article_desc_edit_idx;
			
			layui.use(['form', 'layer', 'laytpl', 'element', 'laydate'], function() {
				var form = layui.form();
				var layer = layui.layer;
				var laytpl = layui.laytpl,
					element = layui.element(),
					laydate = layui.laydate;
					
				
				// 表单验证
				form.verify({
				});

				//监听提交
				form.on('submit(formDemo)', function(formData){
					sendPost("/api/eduorg/class/save", formData.field, function(res) {
						layer.alert(res.msg, {
							title: '信息提示'
						}, function(idx){
							if (res.code==200){
								window.history.back();;
							}
							layer.close(idx);
						});
					});
					return false;
				});

				// 页面初始化
				function page_init(){
					var id = getUrlParam('id');

					// 加载初始化编辑数据
					sendGet("/api/eduorg/class/getOne", {
						id : getUrlParam("id")
					}, function(res) {
						//console.log(res);
						// 初始化编辑数据
						if (res.hasOwnProperty("oneinfo")) {
							$("form.layui-form").setForm(res.oneinfo);
						}
						form.render();
					});
				}
				page_init();
			});
			
			
					
		</script>
	</body>

#end